package com.surprise.webcommon;

import lombok.extern.log4j.Log4j;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.surprise.webcommon.bo.CommonResponse;


/**
 * CommonControllerAdvice.java
 * @author nick
 * 2015年2月10日
 */
@Log4j
//@ControllerAdvice(annotations = { Controller.class }, basePackages = { "com.baidu.search.index.controller", "com.baidu.search.as.controller" })
public class CommonControllerAdvice {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Object handleException(Exception ex) {
        CommonResponse res = new CommonResponse();
        res.setStatus(AppStatusCode.EXCEPTION_OCCUR);
        res.setMsg(ex.getMessage());
        // log error msg
        log.error("exception occurs: ", ex);
        return res;
    }
}
